package com.project.estate.community.controller;

import com.project.estate.commons.bean.Community;
import com.project.estate.commons.config.JsonResult;
import com.project.estate.community.service.CommunityService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/community")
public class CommunityController {

    @Resource
    private CommunityService communityService;

    //添加
    @PostMapping("/add_community")
    public JsonResult addCommunity(Community community) {
        return communityService.addCommunity(community);
    }
    //修改
    @PutMapping("/update_community/{code_id}")
    public JsonResult updateCommunity(Community community, @PathVariable("code_id") String code_id) {
        return communityService.updateCommunity(code_id, community);
    }

    //删除
    @DeleteMapping("/delete_community/{code_id}")
    public JsonResult deleteCommunity(@PathVariable("code_id") String code_id) {
        return communityService.deleteCommunity(code_id);
    }

    //查询
    @GetMapping("/find_community/{code_id}")
    public JsonResult findCommunityByCode( @PathVariable("code_id") String code_id) {
        return communityService.findCommunityById(code_id);
    }

}
